package com.xmotor.test_BitSit_BloomFileter;

/**
 * @Description 加法哈希算法
 * @Author Dang Xianyue
 * @Date 2020-08-04 23:28
 * @Version 1.0
 */
public class Hash {
    private int prime;

    public Hash(int prime) {
        this.prime = prime;
    }

    public int hash(String key){
        int hash, i;
        for (hash = key.length(), i = 0; i < key.length(); i++) {
            hash += key.charAt(i);
        }
        return (hash % prime);
    }
}
